<?php
class Admin_ReportController extends My_Controller_Admin_Choix
{
    protected $_fraisCommAcheteur = null;

    protected function _init()
    {
        $model = new Admin_Model_Ventes();
        $ventes = $model->getVentes($this->_getParam('num_vente'));
        $this->_fraisCommAcheteur = $ventes['com'];
    }

    public function indexAction()
    {
        $numVente = $this->view->numVente;
        $model = new Admin_Model_Report();
        //$model->deleteReleve()->repairReleve($numVente, $this->_fraisCommAcheteur);
        $collection = $model->getClientsCollection($numVente);

        $rowPerPage = $this->_getParam('rowperpage', 20);
        $currentPage = 1;
        $page = $this->_getParam('page', 1);
        if(!empty($page)) {
            $currentPage = $page;
        }
        $paginator = Zend_Paginator::factory($collection);
        $paginator->setItemCountPerPage($rowPerPage);
        $paginator->setCurrentPageNumber($currentPage);

        $this->view->page = $page;
        $this->view->paginator = $paginator;
        //exit;
    }

    public function releveEditAction()
    {
        $id = $this->_getParam('id', 0);
        $data = array();
        if ($id) {
            $model = new Admin_Model_Report();
            $client = $model->getClient($id);
            $numClient = $client['p_clients'];
            $model->calculateReleve($numClient, $this->view->numVente);
        }
        $this->view->object = new My_Object($data);

        //echo 222; exit;
    }
}